import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import VueRouter from 'vue-router'
//导入vue-axios模块
import axios from 'axios'
import VueAxios from 'vue-axios'
Vue.use(VueAxios, axios)

//导入lib-flexible
import 'lib-flexible/flexible'


let naturalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function (location) {
    return naturalPush.call(this, location).catch(err => { })
}
//导入vant组件//注册vant组件
import { Tabbar, TabbarItem, Search } from 'vant';
import { Sidebar, SidebarItem } from 'vant';
import { Skeleton, Toast } from 'vant';
import { NavBar } from 'vant';
import { GoodsAction, GoodsActionIcon, GoodsActionButton } from 'vant';
import { Stepper } from 'vant';
import { Form } from 'vant';
import { Field } from 'vant';
import { Button } from 'vant';
import { Popup } from 'vant';
import { SwipeCell } from 'vant';
import { Checkbox, CheckboxGroup } from 'vant';
import { SubmitBar } from 'vant';
import { Empty } from 'vant';
import { Cell, CellGroup } from 'vant';
import { AddressList } from 'vant';
import { AddressEdit } from 'vant';
import { Uploader } from 'vant';
import { Swipe, SwipeItem } from 'vant';
import { Icon } from 'vant';
import { Switch } from 'vant';
import { Tag } from 'vant';
import { PasswordInput, NumberKeyboard } from 'vant';
import { Overlay } from 'vant';
import { Tab, Tabs } from 'vant';
import { Circle } from 'vant';
import { Slider } from 'vant';
import { ShareSheet } from 'vant';
import { Collapse, CollapseItem } from 'vant';

Vue.use(Collapse);
Vue.use(CollapseItem);
Vue.use(ShareSheet);
Vue.use(Slider);
Vue.use(Circle);
Vue.use(Tab);
Vue.use(Tabs);
Vue.use(Overlay);
Vue.use(Tabbar)
Vue.use(TabbarItem)
Vue.use(Search)
Vue.use(Sidebar);
Vue.use(SidebarItem);
Vue.use(Skeleton)
Vue.use(Toast)
Vue.use(NavBar);
Vue.use(GoodsAction);
Vue.use(GoodsActionButton);
Vue.use(GoodsActionIcon);
Vue.use(Stepper);
Vue.use(Form);
Vue.use(Field);
Vue.use(Button);
Vue.use(Popup);
Vue.use(SwipeCell);
Vue.use(Checkbox);
Vue.use(CheckboxGroup);
Vue.use(SubmitBar);
Vue.use(Empty);
Vue.use(Cell);
Vue.use(CellGroup);
Vue.use(AddressList);
Vue.use(AddressEdit);
Vue.use(Uploader);
Vue.use(Swipe);
Vue.use(SwipeItem);
Vue.use(Icon);
Vue.use(Switch);
Vue.use(Tag);
Vue.use(PasswordInput);
Vue.use(NumberKeyboard);



//[[设置默认基础请求路径]]
axios.defaults.baseURL = 'https://apis.netstart.cn/music';


// [添加[请求拦截器]([每一次请求][之前]触发)]
axios.interceptors.request.use(config => {
    // console.log('请求之前触发');
    // 在发送请求之前做些什么
    // console.log('查看 发送的请求 所携带的数据 ==> config ==> ', config);
    // 获取到 (config.method请求方式)  (config.params get请求数据) (config.data post请求数据)
    // let 公用参数的追加 = "";

    //启动加载提示
    Toast.loading({
        message: '请求中...',
        duration: 0,
        forbidClick: true,
    });

    return config;
}, error => {
    // 对请求错误做些什么

    //关闭加载提示
    Toast.clear();
    return Promise.reject(error);
});


// [添加[响应拦截器]([每一次响应][之前]触发)]
axios.interceptors.response.use(response => {
    // console.log('响应之前触发');
    // 对响应数据做点什么

    //关闭加载提示
    Toast.clear();
    return response;
}, error => {
    // 对响应错误做点什么 

    //关闭加载提示
    Toast.clear();
    return Promise.reject(error);
});




Vue.config.productionTip = false

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')
